package com.cmpe451.nutty.model;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

@Entity
@Table(name = "APP_URL")
public class AppUrl implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue
    @Column(name = "APP_URL_ID")
    private Long id;

    @Column(name = "URL", columnDefinition = "VARCHAR(256)")
    private String url;

    @Column(name = "IS_REGULAR_EXP", nullable = false)
    private boolean isRegularExpression;

    @Column(name = "DESCRIPTION", columnDefinition = "VARCHAR(255)")
    private String description;

    @ManyToMany(fetch = FetchType.EAGER)
    @JoinTable(name = "APP_URL_PRIVILEGE", joinColumns = { @JoinColumn(name = "APP_URL_ID") }, inverseJoinColumns = { @JoinColumn(name = "APP_PRIVILEGE_NAME") })
    private Set<Privilege> privileges = new HashSet<Privilege>();

    public Long getId() {
	return id;
    }

    public void setId(Long id) {
	this.id = id;
    }

    public String getUrl() {
	return url;
    }

    public void setUrl(String url) {
	this.url = url;
    }

    public boolean isRegularExpression() {
	return isRegularExpression;
    }

    public void setRegularExpression(boolean isRegularExpression) {
	this.isRegularExpression = isRegularExpression;
    }

    public String getDescription() {
	return description;
    }

    public void setDescription(String description) {
	this.description = description;
    }

    public Set<Privilege> getPrivileges() {
	return privileges;
    }

    public void setPrivileges(Set<Privilege> privileges) {
	this.privileges = privileges;
    }

}
